﻿using System;
using System.Collections.Generic;
using System.Text;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using System.Windows.Forms;
using PlanningGIS.Framework;
using ESRI.ArcGIS.ADF.BaseClasses;
using PlanningGIS.SelectQuery;

using PlanningGIS.ArcGIS;

namespace pipeui.button
{
    public class QryPipePT : BaseCommand
    {
        IApplication m_Application = null;
        public QryPipePT()
        {
            base.m_caption = "管点号定位";
            base.m_toolTip = base.m_caption;
        }

        public override void OnCreate(object hook)
        {
            m_Application = hook as IApplication;

        }

        public override bool Enabled
        {
            get
            {
                return (m_Application as IFramework).IsMapCtrlactive;
            }
        }

        public override void OnClick()
        {
            FrmQryPipePT thisFrm = new FrmQryPipePT();
            List<IFeatureLayer> FeatLyrs = MapHelper.GetAllLayer<IFeatureLayer>((m_Application as IFramework).MapControl.Map);
            List<IFeatureLayer> FeatLyrsPipePT = new List<IFeatureLayer>();
            int iPP = 0;
            foreach (IFeatureLayer pFeatureLayer in FeatLyrs)
            {
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                if (pFeatureClass.FindField("管点编号") != -1)
                {
                    FeatLyrsPipePT.Add(pFeatureLayer);
                    iPP = iPP + 1;
                }
            }
            if (iPP == 0)
            {
                MessageBox.Show("没有加载管点图层");
                return;
            }
            thisFrm.LyrsPipePT = FeatLyrsPipePT;
            thisFrm.ShowDialog((m_Application as IFramework).MdiForm);
        }
    }
}
